Don't spin on empty fds in `read2` on Unix
authorAlex Crichton <alex@alexcrichton.com>
Mon, 12 Feb 2018 17:27:11 +0000 (09:27 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 12 Feb 2018 17:27:11 +0000 (09:27 -0800)
commitec991ebcb90149281f8601f7a1dd7f621268fd9a
tree765d879229f153b4444110586262d1860f63ca90
parent8c2f353e4a067c350a3685f1738a5d65894dc1e7
Don't spin on empty fds in `read2` on Unix

This commit fixes what I think is some pathological behavior in Cargo where if
one stdio stream is closed before another then Cargo can accidentally spin in a
tight loop and not block appropriately. Previously, for example, if stderr
closed before stdout then Cargo would spin in a `poll` loop continuously getting
notified that stderr is closed.

The behavior is now changed so after a file descriptor is done we stop passing
it to `poll` and instead only pass the one remaining readable file descriptor.
src/cargo/util/read2.rs